<script setup lang="ts">
import { useUserStore } from '@/stores'
import { useRouter } from 'vue-router'
const userStore = useUserStore()

// 退出登录
const router = useRouter()
const logout = () => {
  userStore.userInfo = {
    token: '',
    name: ''
  }
  router.push('/')
}
</script>

<template>
  <el-affix>
    <div class="top">
      <el-row>
        <el-col :span="20" :offset="2">
          <div class="left">
            <h1>logo</h1>
            <h2><RouterLink to="/">尚医通</RouterLink></h2>
            <h3><RouterLink to="/">预约挂号统一平台</RouterLink></h3>
          </div>
          <div class="right">
            <span><RouterLink to="/">帮助中心</RouterLink></span>
            <span v-if="!userStore.userInfo.token"
              ><RouterLink to="" @click="userStore.dialogVisible = true"
                >登录/注册</RouterLink
              ></span
            >
            <span v-else>
              <el-dropdown>
                <span style="margin: 44px auto; cursor: pointer"
                  >欢迎您，{{ userStore.userInfo.name }}</span
                >
                <el-icon><Arrow-down></Arrow-down></el-icon>
                <template #dropdown>
                  <el-dropdown-menu>
                    <el-dropdown-item>实名认证</el-dropdown-item>
                    <el-dropdown-item>挂号订单</el-dropdown-item>
                    <el-dropdown-item>就诊人管理</el-dropdown-item>
                    <el-dropdown-item @click="logout"
                      >退出登录</el-dropdown-item
                    >
                  </el-dropdown-menu>
                </template>
              </el-dropdown>
            </span>
          </div>
        </el-col>
      </el-row>
    </div>
  </el-affix>
</template>

<style lang="scss" scoped>
a {
  text-decoration: none;
  color: #55a6fe;
}
.top {
  background-color: white;
  height: 100px;
  line-height: 100px;
  .el-row {
    height: 100%;
    .el-col {
      display: flex;
      justify-content: space-between;
      .left {
        display: flex;
        h1 {
          margin-right: 10px;
          width: 50px;
          text-indent: -9999px;
          background: url('@/assets/images/logo.png') no-repeat center/50px;
        }
        h2 {
          margin-right: 5px;
          font-size: 30px;
        }
        h3 {
          font-size: 30px;
        }
      }

      .right {
        height: 100px;
        line-height: 100px;
        align-items: center;
        span {
          margin-left: 10px;
          font-size: 14px;
          color: #ccc;
        }
      }
    }
  }
}
</style>
